<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
	<script type="text/javascript">
		function check(id){
				if(confirm("确认删除吗？")){
				$.getJSON("BookManageDeleteServlet","id="+id,function(data){
					if(data.result > 0){
						alert("删除成功！");
						window.location.reload();//刷新当前页面
					}
				})
		}}
	</script>
	<div style="text-align: center;">
		<h1 align="center">图书信息</h1>
		<form action="bookManageAdd.jsp" >
		<table border="1" align="center">
			<tr>
				<th>图书名称</th>
				<th>图书作者</th>
				<th>购买时间</th>
				<th>图书分类</th>
				<th>操作</th>
			</tr>
			<c:forEach var="list" items="${requestScope.list}">
			<tr>
				<td align="center" class="bookID" >${list.id }</td>
				<td align="center">${list.name }</td>
				<td align="center">${list.author }</td>
				<td align="center">${list.time }</td>
				<td align="center" >
				<c:if test="${list.type==1 }">
					计算机/软件
				 </c:if>
				 <c:if test="${list.type==2 }">
					小说/文摘
				 </c:if>
				 <c:if test="${list.type==3 }">
					杂项
				 </c:if>
				</td>
				<td align="center"><a href="#" onclick="check(${list.id})">删除</a></td>
			</tr>
			</c:forEach>
		</table>
		<input type="submit" value="新增图书信息">
		</form>
	</div>
</body>
</html>